#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QGraphicsScene>
#include <QTcpSocket>
#include <QKeyEvent>
#include <QHostAddress>
#include <QPair>

#include <QListWidgetItem>

#include "gamearea.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    
private:
    Ui::MainWindow *ui;

    QGraphicsScene *scene;
    QTcpSocket *client;
    GameArea *game;

    quint32 myID;

    void updatePoints();

    void keyPressEvent(QKeyEvent * event);
    void sendEventToServer(QString str);
    void decode(QString msg);

    void getField(QString msg);
    void getYourSnake(QString msg);
    void getOtherSnakes(QString msg);
    quint32 getNewSnake(QString msg);
    void getUpdate(QString msg);
    void getDisconected(QString msg);
    void getBonus(QString msg);
    void getExistBonuses(QString msg);
    void closeEvent(QCloseEvent *ev);

    quint32 blockSize;

private slots:
    void slotReadyRead();
    void on_pushButton_clicked();
    void on_pushButton_2_clicked();
};

#endif // MAINWINDOW_H
